package com.nolon.flange

import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import com.nolon.flange.R
import com.nolon.flange.databinding.ActivityUserBinding
import com.nolon.flange.viewmodel.UserViewModel
import com.nolon.flange.viewmodel.UserViewModelFactory

class UserActivity : AppCompatActivity() {
    private lateinit var _binding: ActivityUserBinding
    private val bd: ActivityUserBinding get() = _binding
    private lateinit var viewModel: UserViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        _binding = ActivityUserBinding.inflate(layoutInflater)
        setContentView(bd.root)
        setSupportActionBar(bd.toolbar)

        supportActionBar?.apply {
            setDisplayHomeAsUpEnabled(true)
            title = getString(R.string.app_activation)
        }

        val viewModelFactory = UserViewModelFactory(application)
        viewModel = ViewModelProvider(this, viewModelFactory).get(UserViewModel::class.java)
        bd.vm = viewModel
        try {
            viewModel.init(this)
        } catch (e: Exception) {

        }
        bd.editID.keyListener = null
    }

    // 处理按钮点击
    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when (item.itemId) {
            android.R.id.home -> finish()
        }
        return true
    }

    private val SECRET_KEY = "asdfghjklqwertyu"
    private val IV = "1234567899876543"
    private var encryptData = ""
//    <item>CBC</item>
//    <item>CFB</item>
//    <item>ECB</item>

}